

////----- #include "dev_4g.h"   ----------


#ifndef __DEV_4G_H__
#define __DEV_4G_H__

#include <stdint.h>


typedef enum{
    network_init,
    network_ready,
    network_wait_connect,
    network_connected,
}network_state_e;


#define   ICCID_STR_LEN   (24U)//最大有20个字符
#define   IMEI_STR_LEN    (20U)

//  hcat1.CSQ = 28;// 2...30 – -109... -53 dBm
////<rssi>
// 0 – -113 dBm or less
// 1 – -111 dBm
// 2...30 – -109... -53 dBm
// 31 – -51 dBm or greater
// 99 – not known or not detectable


 //  hcat1.BER = 7;  // 7 – >=8.0%
// <ber>
// (in percent)
// 0 – <0.01%
// 1 – 0.01% --- 0.1%
// 2 – 0.1% --- 0.5%
// 3 – 0.5% --- 1.0%
// 4 – 1.0% --- 2.0%
// 5 – 2.0% --- 4.0%
// 6 – 4.0% --- 8.0%
// 7 – >=8.0%
// 99 – not known or not detectable



typedef struct{
    network_state_e network_state;
    //modular info
    char SN[32+1];
    char IMEI[IMEI_STR_LEN];///////IMEI低12位做mac，用于平台管理
    char IMSI[15+1];
    char CSQ;
    char BER;
    char CCID[ICCID_STR_LEN];
    char COPS[32+1];

    //socket info
    int8_t socket;
    //buf
 //   uint8_t rxbuf[1600];
    uint16_t rxlen;
    uint8_t tx_idle;

}cat1_handle_t;

#if  0
typedef struct{
    network_state_e network_state;
    //modular info
    char SN[32+1];
    char IMEI[15+1];
    char IMSI[15+1];
    char CSQ;
    char BER;
    char CCID[20+1];
    char COPS[32+1];
    //socket info
    int8_t socket;
    //buf
    uint8_t rxbuf[1600];
    uint16_t rxlen;
    uint8_t tx_idle;
}cat1_handle_t;

#endif


extern cat1_handle_t hcat1;
extern char connect_err[64];




/**
 * @brief 初始化4g模块信息---
 * 
 * @return null
 */
 void dev_4g_init(void);


/**
 * @brief 
 * 
 * @param error 重连原因，无需加回车
 */
void cat1_reconnect(char* error);

void cat1_state_machine(void);





/////用  plat_send() 代替 cat1_send_data()
////通过注册事件(Event )异步发送---
// void cat1_send_data(int8_t socket, uint8_t* data , uint16_t len);



#endif    ///// __DEV_4G_H__






